﻿$(function () {

    $(".edit").click(function () {
        var pid = $(this).attr("pid");
        location.href = "/MyAdams/Businesses/Create/" + pid;
    });

    $(".renew").click(function () {
        var pid = $(this).attr("pid");

        Ajax({
            url: "/MyAdams/Businesses/Renew/",
            data: JSON.stringify({ BusinessID: pid }),
            success: function (data) {
                if (data.IsSaved == true) {
                    pid = data.ID;
                    $("#p_" + pid + " .exp").fadeOut("slow", function () {
                        $(this).fadeIn("slow");
                    });
                    $("#p_" + pid + " .renew").fadeOut("slow");
                }
            }
        });
    });

    $(".remove").click(function () {
        var pid = $(this).attr("pid");

        if (confirm("are you sure?")) {
            Ajax({
                url: "/MyAdams/Businesses/Remove",
                data: JSON.stringify({ BusinessID: pid }),
                success: function (data) {
                    if (data.IsSaved == true) {
                        pid = data.ID;
                        $("#p_" + pid).fadeOut("slow");
                    }
                }
            });
        }
    });
});
